package main

import (
	"fmt"
	"reflect"
)

// 反射获取任意变量的类型
type myInt int
type Person struct {
	Name string
	Age  int
}

func reflectFn(x interface{}) {
	v := reflect.TypeOf(x)
// 类型种类指的是底层的类型
	fmt.Printf("类型:%v 类型名称:%v 类型种类:%v\n", v, v.Name(), v.Kind())
}

func main() {
	a := 10
	b := 12.3
	c := "hello"
	d := true
	e := []int{1, 2, 3}
	reflectFn(a)
	reflectFn(b)
	reflectFn(c)
	reflectFn(d)
	reflectFn(e)

	var g myInt = 100
	var f = Person{
		Name: "Alice",
		Age:  20,
	}
	reflectFn(g)
	reflectFn(f)

	var h = 25
	reflectFn(&h)

	var j = [3]int{1, 2, 3}
	reflectFn(j)
}
go install -u github.com/gin-gonic/gin